const mongoose = require('mongoose')
const Schema = mongoose.Schema
const AnnouncementSchemaConfig = {
  versionKey: false,
  timestamps: {
    createdAt: 'created_at',
    updatedAt: false
  }
}

const AnnouncementSchema = new Schema({
  icon: Buffer,
  title: String,
  summary: String,
  content: String,
  delete: { type: Boolean, default: false },
  read_times: { type: Number, default: 0 },
  author: { type: Schema.Types.ObjectId, ref: 'User' },
  team: { type: Schema.Types.ObjectId, ref: 'Team' },
  announcement_tag: { type: Schema.Types.ObjectId, ref: 'AnnouncementTag' }
}, AnnouncementSchemaConfig)

AnnouncementSchema.index({ created_at: -1 })
exports = module.exports = AnnouncementSchema
